home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 18 / develop 18 code / OSA Sample / Sources / ScriptableObjects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-28  |  3.4 KB  |  145 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ScriptableObjects.h
  3.  
  4.     Contains:    Script handling & OSA interface
  5.  
  6.     Developed by:    
  7.         
  8.         Paul G Smith (commstalk hq & Full Moon Software, Inc)
  9.         
  10.         you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  11.         BUT I prefer to be contacted by e-mail
  12.         AppleLink:     SMITH.PG
  13.         Internet:     SMITH.PG@applelink.apple.com
  14.         
  15.         "SimpliFace" Sample code to accompany develop article
  16.         on techniques for embedding scripts in applications.
  17.  
  18. */
  19.  
  20.  
  21. #ifndef __SCRIPTOBJECTS__
  22. #define __SCRIPTOBJECTS__
  23.  
  24.  
  25. #ifndef __APPLEEVENTS__
  26. #include "AppleEvents.h"
  27. #endif
  28.  
  29. #ifndef __PASCALSTRING__
  30. #include <PascalString.h>
  31. #endif
  32.  
  33. #ifndef __AERegistry__
  34. #include <AERegistry.h>
  35. #endif
  36.  
  37. #ifndef __OSA__
  38. #include <OSA.h>
  39. #endif
  40.  
  41. #ifndef __LISTOFLONGS__
  42. #include "ListOfLongs.h"
  43. #endif
  44.  
  45.  
  46.  
  47.  
  48. class TScriptableObject : HandleObject
  49. {
  50. public:
  51.     // Our constructor & destructor
  52.                     TScriptableObject();
  53.     virtual         ~TScriptableObject();
  54.  
  55.     virtual  OSErr CountElements (DescType desiredClass,
  56.                                         long *result);
  57.                                         
  58.     virtual  OSErr CompareWith   (DescType comparisonOperator,
  59.                                         const TScriptableObject *objToCompare,
  60.                                         Boolean *result);
  61.     
  62.     virtual  OSErr ResolveContainer    (TScriptableObject **theContainerObj);
  63.                                         
  64.     virtual  OSErr ResolveElementByName(DescType desiredClass,
  65.                                         CStr255& nameStr,
  66.                                         TScriptableObject **theResultObj);
  67.                                         
  68.     virtual  OSErr ResolveElementByIndex(DescType desiredClass,
  69.                                         short theIndex,
  70.                                         TScriptableObject **theResultObj);
  71.     
  72.     virtual  OSErr OpenObject  (void);
  73.                                         
  74.     virtual  OSErr CloseObject  (void);
  75.  
  76.     virtual  OSErr GetData  (AEDesc *result);
  77.                                                 
  78.     virtual  OSErr SetData  (const AEDesc *theData);    
  79.                                         
  80.     virtual  OSErr GetProperty  (DescType propertyID, DescType wantType, AEDesc *result);
  81.                                                 
  82.     virtual  OSErr SetProperty  (DescType propertyID, const AEDesc *theData);    
  83.  
  84.     virtual     OSErr CreateNewElement    (DescType desiredClass,
  85.                                         DescType position,
  86.                                         AEDesc *theData,
  87.                                         AERecord *theProperties,
  88.                                         TScriptableObject *theContainerObj,
  89.                                         TScriptableObject **theNewObj);
  90.     
  91.     virtual  OSErr DeleteObject  (void);
  92.                                         
  93.     virtual  OSErr GetObjectSpecifier  (AEDesc *result);
  94.                                         
  95.     virtual  OSErr GetTargetObjectSpecifier  (EventRecord& theEvent, AEDesc *result);
  96.     
  97.              OSAID GetObjScript(void)  { return fAttachedScript; };
  98.             
  99. protected:
  100.     OSAID                fAttachedScript;
  101. };
  102.  
  103.  
  104. class TScriptAdministrator : HandleObject
  105. {                                            
  106. public:
  107.     // Our constructor & destructor
  108.                             TScriptAdministrator();
  109.     virtual                 ~TScriptAdministrator();
  110.     
  111.     virtual        OSAID        GetAttachedScript(TScriptableObject* theObj);
  112.     
  113.     virtual        OSAError    ReleaseAttachedScript(TScriptableObject* theObj);
  114.                 
  115.                 void        RunStartupScript(void);
  116.  
  117.                 OSAError    DoScript(AEDesc *scriptDesc, AEDesc *resultDesc);
  118.                 
  119.                 OSAError    LoadScriptFromFile(FSSpec *fileSpec, OSAID *theScriptID);
  120.                 OSAError    SaveScriptToFile(FSSpec *fileSpec, OSAID theScriptID);
  121.                 
  122.                 Boolean        StartupScriptIsRunning(void) { return fStartupScriptRunning; }; 
  123.  
  124. protected:
  125.     FSSpec                fPrefsFileSpec;
  126.     Boolean                fStartupScriptRunning;    // we must not run it recursively
  127. };
  128.  
  129.  
  130.  
  131. // globals & global routines
  132.  
  133. extern    TScriptAdministrator*    gScriptAdministrator;
  134. extern    ComponentInstance        gScriptingComponent;
  135. extern    AEAddressDesc            gSelfAddress;
  136. extern    ProcessSerialNumber        gSelfPSN;
  137.  
  138.  
  139. OSAError StartScriptAdministrator(void);
  140.  
  141. OSAError StopScriptAdministrator(void);
  142.  
  143.  
  144. #endif
  145.